package logger

var DefaultGlobalLevel = LevelDebug
var DefaultLogger *Logger
var DefaultTargetStdout = &TargetStdout{}
var GlobalSwitch = makeSwitch()

var DefaultContextPool = IContextPool(newContextPool(256))

var DefaultFormatterJson = &FormatterJson{}

var DefaultFormatterSeparator = &FormatterSeparator{
	Separator:   "|",
	KVSeparator: "=",
}

func init() {
	//为ContextPool预准备一些context
	cl := make([]*Context, 0, 64)
	for i := 0; i < DefaultContextPool.PoolSize() && i < 64; i++ {
		cl = append(cl, DefaultContextPool.Get())
	}
	for _, ctx := range cl {
		ctx.release()
	}

	l, err := NewLogger(&LoggerConfig{
		CodeLineSkipCaller: 3,
	})
	if err != nil {
		panic(err)
	}
	DefaultLogger = l
}

func ResetDefaultLogger(l *Logger) {
	l.Config.CodeLineSkipCaller = 3
	DefaultLogger = l
}

func TRC() IContext {
	return DefaultLogger.TRC()
}

func DBG() IContext {
	return DefaultLogger.DBG()
}
func INF() IContext {
	return DefaultLogger.INF()
}
func WRN() IContext {
	return DefaultLogger.WRN()
}
func ERR() IContext {
	return DefaultLogger.ERR()
}
func FAT() IContext {
	return DefaultLogger.FAT()
}
